package com.sanpu.kxe.business.main.adapter;

import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sanpu.kxe.R;
import com.sanpu.kxe.business.main.bean.NoticeOutput;

import java.util.ArrayList;

/**
 * Description：消息列表
 * Created by 薛勇军 on 2018/7/23.
 */

public class NoticeAdapter extends BaseQuickAdapter<NoticeOutput, BaseViewHolder> {

    public NoticeAdapter() {
        super(R.layout.item_notice, new ArrayList<NoticeOutput>());
    }

    @Override
    protected void convert(BaseViewHolder helper, NoticeOutput item) {
        if (item != null) {
            helper.setText(R.id.date, !TextUtils.isEmpty(item.getGenerateTime())
                            ? item.getGenerateTime() : "")
                    .setText(R.id.des, !TextUtils.isEmpty(item.getDetail()) ? item.getDetail().trim() : "");
            TextView titleTv = helper.getView(R.id.title);
            if (!TextUtils.isEmpty(item.getTitle())) {
                titleTv.setText(item.getTitle());
            } else {
                titleTv.setText("");
            }
            if (!item.isMsgRead()) {
                titleTv.setTextColor(ContextCompat.getColor(mContext, R.color.red));
            } else {
                titleTv.setTextColor(ContextCompat.getColor(mContext, R.color.black));
            }
        }
    }
}
